﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Spinning.Spinning.Unitity;
using Microsoft.Xna.Framework;
using Spinning.Spinning.EntityModifiers;
using Spinning.Spinning.Level;
using Microsoft.Xna.Framework.Input.Touch;

namespace Spinning.Spinning.Entity.Scenes
{
    class TeachWaterScene : TeachScene
    {
        

        public override void OnLoad()
        {
            base.OnLoad();
            Sprite sprite1 = new Sprite();
            sprite1.textureName = "teachWater/water_1";
            sprite1.ZIndex = Constants.background;
            sprite1.Alpha = 1;
            sprite1.OnLoad();
            _sprites.Add(sprite1);
            this.Attach(sprite1);

            Sprite sprite2 = new Sprite();
            sprite2.textureName = "teachWater/water_2";
            sprite2.ZIndex = Constants.background;
            sprite2.Alpha = 0;
            sprite2.OnLoad();
            _sprites.Add(sprite2);
            this.Attach(sprite2);

            Sprite sprite3 = new Sprite();
            sprite3.textureName = "teachWater/water_3";
            sprite3.ZIndex = Constants.background;
            sprite3.Alpha = 0;
            sprite3.OnLoad();
            _sprites.Add(sprite3);
            this.Attach(sprite3);

            spriteText = new Sprite();
            spriteText.textureName = "teachWater/water_text";
            spriteText.ZIndex = Constants.ui;
            spriteText.Alpha = 0;
            spriteText.Position = new Vector2(240-165, 200);
            spriteText.OnLoad();
            this.Attach(spriteText);

        }

        int _gameTime,flag;

        protected override void UpdateSelf(GameTime gameTime)
        {
            base.UpdateSelf(gameTime);
            int delta = gameTime.ElapsedGameTime.Milliseconds;
            _gameTime += delta;
            if (_gameTime / 1000 >= 1)
            {
                flag = -flag + 1;
                _gameTime = _gameTime % 1000;
            }
            if (flag == 0) spriteText.Alpha = ((float)(_gameTime % 1000) / 1000) * 0.7f + 0.3f;
            else spriteText.Alpha = (1f - (float)(_gameTime % 1000) / 1000) * 0.7f + 0.3f;
        }

        public override void OnStartFunction()
        {
            Game1.stageManager.GoToScene("water");
        }

        public override BaseScene Clone()
        {
            BaseScene scene = new TeachWaterScene();
            scene.Size = new Vector2(Constants.Window_Width, Constants.Window_Height);
            scene.OnLoad();
            scene.SortChildren();
            return scene;
        }
    }
}
